package com.lzs.chuku.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lzs.entity.ReviewDetail;
import com.lzs.chuku.service.ReviewDetailService;
import com.lzs.util.R;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.management.Query;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 刘中帅
 * @since 2020-11-23
 */
@RestController
@RequestMapping("/chuku/review-detail")
public class ReviewDetailController {
    @Autowired
    private ReviewDetailService reviewDetailService;
   @PostMapping("addReviewDetail")
    @ApiOperation("新增复核明细")
    public R addReviewDetail(@RequestBody ReviewDetail reviewDetail){
        return reviewDetailService.addReviewDetail(reviewDetail);
   }
    @GetMapping("findReviewDetailsByPid/{id}")
    @ApiOperation("根据复核id查询复核明细")
    public R findReviewDetailsByPid(@PathVariable("id") Long id){
       try {
           QueryWrapper<ReviewDetail> wrapper = new QueryWrapper<>();
           wrapper.eq("pid", id);
           List<ReviewDetail> list = reviewDetailService.list(wrapper);
           return R.ok().data("list",list);
       }catch (RuntimeException e){
           return R.error();
       }
    }
}

